/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entidades;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Damian
 */
@Entity
@Table(name = "offer")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Offer.findAll", query = "SELECT o FROM Offer o"),
    @NamedQuery(name = "Offer.findByIdOffer", query = "SELECT o FROM Offer o WHERE o.idOffer = :idOffer"),
    @NamedQuery(name = "Offer.findByDesc", query = "SELECT o FROM Offer o WHERE o.desc = :desc"),
    @NamedQuery(name = "Offer.findByPrice", query = "SELECT o FROM Offer o WHERE o.price = :price"),
    @NamedQuery(name = "Offer.findByVotes", query = "SELECT o FROM Offer o WHERE o.votes = :votes"),
    @NamedQuery(name = "Offer.findByCreationDate", query = "SELECT o FROM Offer o WHERE o.creationDate = :creationDate"),
    @NamedQuery(name = "Offer.findByModifDate", query = "SELECT o FROM Offer o WHERE o.modifDate = :modifDate"),
    @NamedQuery(name = "Offer.findByIndActive", query = "SELECT o FROM Offer o WHERE o.indActive = :indActive")})
public class Offer implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "ID_OFFER")
    private Integer idOffer;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 250)
    @Column(name = "DESC")
    private String desc;
    @Basic(optional = false)
    @NotNull
    @Column(name = "PRICE")
    private double price;
    @Column(name = "VOTES")
    private Integer votes;
    @Basic(optional = false)
    @NotNull
    @Column(name = "CREATION_DATE")
    @Temporal(TemporalType.DATE)
    private Date creationDate;
    @Basic(optional = false)
    @NotNull
    @Column(name = "MODIF_DATE")
    @Temporal(TemporalType.DATE)
    private Date modifDate;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 1)
    @Column(name = "IND_ACTIVE")
    private String indActive;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idOffer")
    private Collection<OfferDay> offerDayCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idOffer")
    private Collection<OfferHourly> offerHourlyCollection;
    @JoinColumn(name = "ID_LOCAL", referencedColumnName = "ID_LOCAL")
    @ManyToOne(optional = false)
    private Local idLocal;
    @JoinColumn(name = "ID_TYPE", referencedColumnName = "ID_OFFER_TYPE")
    @ManyToOne(optional = false)
    private OfferType idType;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idOffer")
    private Collection<OfferDayWeek> offerDayWeekCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idOffer")
    private Collection<OfferComment> offerCommentCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idOffer")
    private Collection<OfferDayMonth> offerDayMonthCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idOffer")
    private Collection<OfferImages> offerImagesCollection;

    public Offer() {
    }

    public Offer(Integer idOffer) {
        this.idOffer = idOffer;
    }

    public Offer(Integer idOffer, String desc, double price, Date creationDate, Date modifDate, String indActive) {
        this.idOffer = idOffer;
        this.desc = desc;
        this.price = price;
        this.creationDate = creationDate;
        this.modifDate = modifDate;
        this.indActive = indActive;
    }

    public Integer getIdOffer() {
        return idOffer;
    }

    public void setIdOffer(Integer idOffer) {
        this.idOffer = idOffer;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public Integer getVotes() {
        return votes;
    }

    public void setVotes(Integer votes) {
        this.votes = votes;
    }

    public Date getCreationDate() {
        return creationDate;
    }

    public void setCreationDate(Date creationDate) {
        this.creationDate = creationDate;
    }

    public Date getModifDate() {
        return modifDate;
    }

    public void setModifDate(Date modifDate) {
        this.modifDate = modifDate;
    }

    public String getIndActive() {
        return indActive;
    }

    public void setIndActive(String indActive) {
        this.indActive = indActive;
    }

    @XmlTransient
    public Collection<OfferDay> getOfferDayCollection() {
        return offerDayCollection;
    }

    public void setOfferDayCollection(Collection<OfferDay> offerDayCollection) {
        this.offerDayCollection = offerDayCollection;
    }

    @XmlTransient
    public Collection<OfferHourly> getOfferHourlyCollection() {
        return offerHourlyCollection;
    }

    public void setOfferHourlyCollection(Collection<OfferHourly> offerHourlyCollection) {
        this.offerHourlyCollection = offerHourlyCollection;
    }

    public Local getIdLocal() {
        return idLocal;
    }

    public void setIdLocal(Local idLocal) {
        this.idLocal = idLocal;
    }

    public OfferType getIdType() {
        return idType;
    }

    public void setIdType(OfferType idType) {
        this.idType = idType;
    }

    @XmlTransient
    public Collection<OfferDayWeek> getOfferDayWeekCollection() {
        return offerDayWeekCollection;
    }

    public void setOfferDayWeekCollection(Collection<OfferDayWeek> offerDayWeekCollection) {
        this.offerDayWeekCollection = offerDayWeekCollection;
    }

    @XmlTransient
    public Collection<OfferComment> getOfferCommentCollection() {
        return offerCommentCollection;
    }

    public void setOfferCommentCollection(Collection<OfferComment> offerCommentCollection) {
        this.offerCommentCollection = offerCommentCollection;
    }

    @XmlTransient
    public Collection<OfferDayMonth> getOfferDayMonthCollection() {
        return offerDayMonthCollection;
    }

    public void setOfferDayMonthCollection(Collection<OfferDayMonth> offerDayMonthCollection) {
        this.offerDayMonthCollection = offerDayMonthCollection;
    }

    @XmlTransient
    public Collection<OfferImages> getOfferImagesCollection() {
        return offerImagesCollection;
    }

    public void setOfferImagesCollection(Collection<OfferImages> offerImagesCollection) {
        this.offerImagesCollection = offerImagesCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idOffer != null ? idOffer.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Offer)) {
            return false;
        }
        Offer other = (Offer) object;
        if ((this.idOffer == null && other.idOffer != null) || (this.idOffer != null && !this.idOffer.equals(other.idOffer))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entidades.Offer[ idOffer=" + idOffer + " ]";
    }
    
}
